package tju.acm;

import java.util.Arrays;
import java.util.Scanner;

/**
 * 数组的最大排序 与 数组的最小排序相乘
 * 
 * */
public class poj3508MinimumScalarProduct {

	public static long[] sortArrayAsc(long[] intArr) {
		
		Arrays.sort(intArr);
		return intArr;
	}
	
	public static long[] sortArrayDesc(long[] intArr) {
		
		Arrays.sort(intArr);
		int len = intArr.length;
		
		long[] newArr = new long[len];
		
		for (int i=0;i<intArr.length;i++) {
			newArr[i] = intArr[intArr.length-i-1];
		}
		
		return newArr;
	}
	
	public static long scalarProduct(long[] a,long[] b) {
		
		long res = 0L;
		if (a.length!=b.length)
			return res;
		else {
			for (int i=0;i<a.length;i++) {
				res += a[i]*b[i];
			}
			return res;
		}
			
	}
	
	public static void main (String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int caseNum = sc.nextInt();
		
		int vectLen;
		long[] vect1,vect2;
		
		for (int i=0;i<caseNum;i++) {
			
			vectLen = sc.nextInt();
			
			vect1 = new long[vectLen];
			vect2 = new long[vectLen];
			
			for (int j=0;j<vectLen;j++) {
				vect1[j] = sc.nextLong();
			}
			
			for (int j=0;j<vectLen;j++) {
				vect2[j] = sc.nextLong();
			}
			
			vect1 = sortArrayAsc(vect1);
			vect2 = sortArrayDesc(vect2);
			
			long result =  scalarProduct(vect1,vect2);
			
			System.out.println("Case #"+(i+1)+": "+result);
		}
		
	}
}
